import { ColumnGroupType, ColumnType } from "antd/es/table"

import { parseVirtualCurrency } from "@/utils/util"

const risk = (
	newFormat: (arg: string) => string,
	_getFromDic: (arg: string, strictlyLabel?: boolean) => any
): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	terminalInfo: {
		key: "terminalInfo",
		align: "center",
		dataIndex: "terminalInfo",
		title: newFormat("member.register_ip"),
		width: 200
	},
	ipAttribution: {
		key: "ipAttribution",
		align: "center",
		width: 200,
		dataIndex: "ipAttribution",
		title: newFormat("member.ip_attribution")
	},
	terminalRegister: {
		key: "terminalRegister",
		align: "center",
		dataIndex: "terminalInfo",
		title: newFormat("risk.terminal_info_register")
	},
	terminalLoginDevice: {
		key: "terminalLoginDevice",
		align: "center",
		dataIndex: "terminalInfo",
		title: newFormat("risk.terminal_info")
	},
	terminalLoginIp: {
		key: "terminalLoginIp",
		align: "center",
		dataIndex: "terminalInfo",
		title: newFormat("member.login_ip_member")
	},
	windControlType: {
		key: "windControlType",
		align: "center",
		dataIndex: "windControlType",
		title: newFormat("table.risk_type"),
		render: _getFromDic("windLevelType", false),
		ellipsis: true,
		width: 200
	},
	windControlLevelName: {
		key: "windControlLevelName",
		align: "center",
		dataIndex: "windControlLevelName",
		title: newFormat("table.risk_level"),
		width: 150
	},
	windControlLevelValue: {
		key: "windControlLevelValue",
		align: "center",
		dataIndex: "windControlLevelValue",
		title: newFormat("table.risk_level"),
		width: 150
	},
	objectInfo: {
		key: "objectInfo",
		align: "center",
		dataIndex: "objectInfo",
		width: 200,
		title: newFormat("table.risk_target"),
		render: (value, row) => {
			if (row.windControlType === 3 || row.windControlType === 4) {
				return parseVirtualCurrency(value)
			}
			return value || "-"
		}
	},
	windDescription: {
		title: newFormat("table.risk_reason"),
		dataIndex: "windDescription",
		align: "center",
		width: 200
	},
	riskLevelDescription: {
		title: newFormat("table.risk_level_description"),
		dataIndex: "description",
		align: "center",
		width: 200
	}
})
export default risk
